
/*
	设置用于保存session数据的cookie过期时间
	在express.session()的参数中设置
*/

var express = require('express');
var fs = require('fs');
var app = express();

app.use(express.cookieParser());
// app.use(express.session({secret: 'test'}));
app.use(express.session({secret: 'test', cookie:{maxAge:3600}}));

app.get('/index.html', function(req, res){
	res.sendfile(__dirname + '/session_index.html');
	req.session.username = 'xuxuan';
	req.session.password = '123456';
});

app.post('/index.html', function(req, res){
	console.log(req.session)
	console.log(req.session.username);
	console.log(req.session.password);
	/*
	{
		cookie: {
			path: '/',
			_expires: null,
			originalMaxAge: null,
			httpOnly: true
		},
		username: 'xuxuan',
		password: '123456'
	}
	xuxuan
	123456
	*/


	/*
	app.use(express.session({secret: 'test', cookie:{maxAge:3600000}}));
	{
		cookie: {
			path: '/',
			_expires: Wed Oct 15 2014 11: 36: 46 GMT + 0800(中国标准时间),
			originalMaxAge: 3600000,
			httpOnly: true
		},
		username: 'xuxuan',
		password: '123456'
	}
	xuxuan
	123456
	*/
	res.end();
});

app.listen(1337, 'localhost');